﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.IO;

namespace Titler.Views
{
    /// <summary>
    /// Interaction logic for PMWindow.xaml
    /// </summary>
    public partial class PMView : Window
    {

        public PMView()
        {
            InitializeComponent();
        }



        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var theButton = sender as Button;
            bool isDwg = theButton.ToString().Contains("Dwg") == true ? true : false;
            int isLevel = theButton.ToString().Contains("GMA") == true ? 3 : theButton.ToString().Contains("MA") == true ? 2 : 1;

            var newThread = new Controls.ThreadCtrl();
            var newMaterial = new Controls.MaterialCtrl();
            var newMandrel = new Controls.MandrelCtrl();
            var newGauge = new Controls.GaugeCtrl();
            var newChemical = new Controls.ChemicalCtrl();

            string ThreadTitle = newThread.TitleReturn();
            string MaterialTitle = newMaterial.TitleReturn();
            string[] MandrelTitle = newMandrel.TitleReturn();
            string[] GaugeTitle = newGauge.TitleReturn(isDwg, isLevel);
            string ChemicalTitle = newChemical.TitleReturn(isDwg, isLevel);

            string TitleStart = 
                isLevel == 3 && MandrelTitle[1] == "Flowmeter" ? "FLOWMETER MANDREL ASSEMBLY" : 
                isLevel == 3 && GaugeTab.IsSelected == true ? "GAUGE MANDREL ASSEMBLY" : 
                isLevel == 3 && ChemicalTab.IsSelected == true ? "CHEMICAL INJECTION MANDREL ASSEMBLY" : 
                isLevel == 3 && ComboTab.IsSelected == true ? "GAUGE AND CHEMICAL INJECTION MANDREL ASSEMBLY" : 
                isLevel == 2 && MandrelTitle[1] == "Flowmeter" ? "MANDREL ASSEMBLY, FLOWMETER" : 
                isLevel == 2 && GaugeTab.IsSelected == true ? "MANDREL ASSEMBLY" : 
                isLevel == 2 && ChemicalTab.IsSelected == true ? "MANDREL ASSEMBLY, CHEMICAL INJECTION" : 
                isLevel == 2 && ComboTab.IsSelected == true ? "MANDREL ASSEMBLY, GAUGE AND CHEMICAL INJECTION" : 
                isLevel == 1 && MandrelTitle[1] == "Flowmeter" ? "MANDREL, FLOWMETER" : 
                isLevel == 1 && GaugeTab.IsSelected == true ? "MANDREL" : 
                isLevel == 1 && ChemicalTab.IsSelected == true ? "MANDREL, CHEMICAL INJECTION" : 
                isLevel == 1 && ComboTab.IsSelected == true ? "MANDREL, GAUGE AND CHEMICAL INJECTION" : "";

            string finalTitle =
                TitleStart + ", " +
                ThreadTitle + ", " +
                (GaugeTab.IsSelected == true ? GaugeTitle[0] : 
                    ChemicalTab.IsSelected == true ? ChemicalTitle : 
                    GaugeTitle[0] + ", " + ChemicalTitle) + 
                (isDwg == false ? ", " + MaterialTitle : "") +
                (MandrelTitle[0] == "Bypass" ? ", BYPASS" : "") +
                (isLevel == 3 && ChemicalTab.IsSelected == false ? ", " + GaugeTitle[1] : "");

            Clipboard.SetText(finalTitle);
        }
    }
}